Skip to main content
Version: 6.0.0-beta.3 - 6.0.0-beta.4

address

Object that allows you to convert between hex / base58 and privatekey representations of a TRON address.

❗️Note:

If you wish to convert generic data to hexadecimal strings, please use the function TronWeb.toHex.

There are three util functions in TronWeb.address object, they are fromHex, toHex, fromPrivateKey.

1. TronWeb.address.toHex

Convert Base58 format address to Hex format address.

Usage

TronWeb.address.toHex('base58 format address');

Parameters

string - Base58 format address

Returns

string - TRON Hex format address

Example

TronWeb.address.toHex('TNPeeaaFB7K9cmo4uQpcU32zGK8G1NYqeL');
> '418840E6C55B9ADA326D211D818C34A994AECED808'

2. TronWeb.address.fromHex

Convert Hex format address to Base58 format address.

Usage

TronWeb.address.fromHex('hex format address');

Parameters

string - Hex format address

Returns

string - TRON Base58 format address

Example

TronWeb.address.fromHex('418840E6C55B9ADA326D211D818C34A994AECED808');
> 'TNPeeaaFB7K9cmo4uQpcU32zGK8G1NYqeL'

3. TronWeb.address.fromPrivateKey

Derive its corresponding address based on the provided private key.

Usage

TronWeb.address.fromPrivateKey('hex format address');

Parameters

string - private key without prefix 0x

Returns

string - Base58 format address

Example

TronWeb.address.fromPrivateKey('3481E79956D4BD95F358AC96D151C976392FC4E3FC132F78A847906DE588C145');
> 'TNPeeaaFB7K9cmo4uQpcU32zGK8G1NYqeL'
// The provided private key is not allowed to start with prefix `0x`, otherwise it will return false
TronWeb.address.fromPrivateKey('0x3481E79956D4BD95F358AC96D151C976392FC4E3FC132F78A847906DE588C145');
> false